package com.aaa.controller.sas;


import com.github.pagehelper.PageInfo;
import com.aaa.entity.LayData;
import com.aaa.entity.MyPage;
import com.aaa.entity.sas.TQuestionSas;
import com.aaa.service.sas.SasService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("tQuestionSas")
public class SasTitleController {
    @Autowired
    private SasService tQuestionSasService;

    @GetMapping("queryAll")
    public LayData queryAll(MyPage myPage, TQuestionSas tQuestionSas) {
        System.out.println("tQuestionSas = " + tQuestionSas);
        PageInfo tQuestionSass = tQuestionSasService.queryAll(myPage, tQuestionSas);
        return new LayData(tQuestionSass);
    }
    @PostMapping("registerQuestion")
    public LayData registerQuestion(TQuestionSas tQuestionSas){
        boolean status = tQuestionSasService.insertQuestion(tQuestionSas);
        return new LayData(status);
    }
    @PostMapping("queryByName")
    public LayData queryByName(String question){
        boolean status = tQuestionSasService.queryQuestion(question);
        return new LayData(status);
    }

    @PostMapping("deleteRole")
    public LayData deleteRole(Integer id){
        boolean status = tQuestionSasService.deleteQuestion(id);
        return new LayData(status);
    }

    /**
     * 批量导入题库
     * @param file
     * @return
     */
    @PostMapping("uploadInfo")
    @ResponseBody
    public LayData uploadInfo(MultipartFile file){
        return new LayData(tQuestionSasService.uploadExcel(file));
    }


}
